package renda.common;

import org.apache.struts2.ServletActionContext;

import renda.pojo.Users;

public class SessionUtil {

	public static void setAttr(String name, Object value) {
		ServletActionContext.getRequest().getSession().setAttribute(name, value);
	}

	public static String getAttr(String name) {
		Object value = ServletActionContext.getRequest().getSession().getAttribute(name);
		if (value != null) {
			return value.toString();
		}
		return "";
	}

	public static Object getAttrObj(String name) {
		Object value = ServletActionContext.getRequest().getSession().getAttribute(name);
		return value;
	}

	public static String getRequestPara(String name) {
		Object value = ServletActionContext.getRequest().getParameter(name);
		if (value != null) {
			return value.toString();
		}
		return "";
	}

	public static Users getCurrentUsers() {
		return (Users) SessionUtil.getAttrObj("curruser");
	}

	public static Integer getCurrentUserType() {
		return (Integer) SessionUtil.getAttrObj(Constants.USER_TYPE);
	}
}
